<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>长按事件</title>
</head>
<body>
    <input id="btn1" type="button" value="长按事件" onmousedown="down()" onmouseup="up()" onclick="cli()">
    <br/>
    <progress value="0" max="100"></progress>
    <script>
        let progress=document.getElementsByTagName('progress')[0];
        let time="";
        let lock=true;
        function down(){
            time=setInterval(()=>{
                lock=false;
                progress.value+=5
            },1000)
        }
        function up(){
           clearInterval(time);
           setTimeout(()=>{
               lock=true;
           })
        }
        function cli(){
            if(lock){
                alert(progress.value);
            }
        }
    </script>
</body>
</html>